<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>原型模式</title>
    <script src="../../package/vueJS/vue.min.js"></script>
</head>

<body>
    <script>
        const people = {
            name: "ldq",
            sex: "男",
            tall: '185',
            say:function(){
                console.log("我是一个人见人爱的第七期将会是,我今年"+this.age);
            },
            init:function(age){
                this.age = age
            }
        }
        // 方法一  object.create(null)
        let lidaqing = Object.create(people)
        lidaqing.age = 19
        lidaqing.say()
        // lidaqing.__proto__.name = 10
        // console.log(lidaqing.__proto__);
        // console.log(people)

        // 方法二 使用 prototype
        function demo(age) {
            function p() { }
            p.prototype = people
            var p = new p()
            p.init(age)
            return p
        }
        var wushu = demo(20)
        wushu.say()
    </script>
</body>

</html>